home *** CD-ROM | disk | FTP | other *** search
Wrap
RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt((((3333CCCC++++++++)))) RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt((((3333CCCC++++++++)))) NNNNaaaammmmeeee RWTValMultiSet<T,C> - Rogue Wave library class SSSSyyyynnnnooooppppssssiiiissss #include <rw/tvmset.h> RWTValMultiSet<T,C> SSSSttttaaaannnnddddaaaarrrrdddd CCCC++++++++ LLLLiiiibbbbrrrraaaarrrryyyy DDDDeeeeppppeeeennnnddddeeeennnntttt!!!! RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt requires the Standard C++ Library. DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn This class maintains a collection of values, which are ordered according to a comparison object of type CCCC. CCCC must induce a total ordering on elements of type T via a public member bbbboooooooollll ooooppppeeeerrrraaaattttoooorrrr(((())))((((ccccoooonnnnsssstttt TTTT&&&& xxxx,,,, ccccoooonnnnsssstttt TTTT&&&& yyyy)))) ccccoooonnnnsssstttt which returns ttttrrrruuuueeee if xxxx should precede yyyy within the collection. The structure lllleeeessssssss<<<<TTTT>>>> from the C++-standard header file <<<<ffffuuuunnnnccccttttiiiioooonnnnaaaallll>>>> is an example. RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt<<<<TTTT,,,,CCCC>>>> may contain multiple items that compare equal to each other. (RRRRWWWWTTTTVVVVaaaallllSSSSeeeetttt<<<<TTTT,,,,CCCC>>>> will not accept an item that compares equal to an item already in the collection.) PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee Isomorphic. EEEExxxxaaaammmmpppplllleeeessss In this example, a multi-set of RRRRWWWWCCCCSSSSttttrrrriiiinnnnggggs is exercised. // // tvmsstr.cpp // #include <rw/tvmset.h> #include <rw/cstring.h> #include <iostream.h> main(){ RWTValMultiSet<RWCString,less<RWCString> > set; set.insert("one"); set.insert("two"); set.insert("three"); set.insert("one"); // OK, duplicates allowed cout << set.entries() << endl; // Prints "4" return 0; } PPPPaaaaggggeeee 1111 RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt((((3333CCCC++++++++)))) RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt((((3333CCCC++++++++)))) RRRReeeellllaaaatttteeeedddd CCCCllllaaaasssssssseeeessss Class RRRRWWWWTTTTVVVVaaaallllSSSSeeeetttt<<<<TTTT,,,,CCCC>>>> offers the same interface to a collection that will not accept multiple items that compare equal to each other. RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiMMMMaaaapppp<<<<KKKK,,,,TTTT,,,,CCCC>>>> maintains a collection of key-value pairs. Class mmmmuuuullllttttiiiisssseeeetttt<<<<TTTT,,,,CCCC,,,,aaaallllllllooooccccaaaattttoooorrrr>>>> is the C++-standard collection that serves as the underlying implementation for RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt<<<<TTTT,,,,CCCC>>>>. PPPPuuuubbbblllliiiicccc TTTTyyyyppppeeeeddddeeeeffffssss typedef multiset<T,C,allocator> container_type; typedef container_type::iterator iterator; typedef container_type::const_iterator const_iterator; typedef container_type::size_type size_type; typedef T value_type; typedef const T& const_reference; PPPPuuuubbbblllliiiicccc CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrrssss RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt<<<<TTTT,,,,CCCC>>>>(const C& cmp = C()); Constructs an empty set. RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt<<<<TTTT,,,,CCCC>>>>(const container_type& s); Constructs a set by copying all elements of ssss. RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt<<<<TTTT,,,,CCCC>>>>(const RWTValMultiSet<T,C>& rws); Copy constructor. RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt<<<<TTTT,,,,CCCC>>>> (const T* first,const T* last,const C& cmp = C()); Constructs a set by copying elements from the array of TTTTs pointed to by ffffiiiirrrrsssstttt, up to, but not including, the element pointed to by llllaaaasssstttt. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr OOOOppppeeeerrrraaaattttoooorrrrssss RWTValMultiSet<T,C>& ooooppppeeeerrrraaaattttoooorrrr====(const RWTValMultiSet<T,C>& s); RWTValMultiSet<T,C>& ooooppppeeeerrrraaaattttoooorrrr====(const container_type& s); Destroys all elements of self and replaces them by copying all elements of ssss. PPPPaaaaggggeeee 2222 RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt((((3333CCCC++++++++)))) RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt((((3333CCCC++++++++)))) bool ooooppppeeeerrrraaaattttoooorrrr<<<<(const RWTValMultiSet<T,C>& s) const; bool ooooppppeeeerrrraaaattttoooorrrr<<<<(const container_type& s) const; Returns ttttrrrruuuueeee if self compares lexicographically less than ssss, otherwise returns ffffaaaallllsssseeee. Assumes that type TTTT has well-defined less-than semantics (TTTT::::::::ooooppppeeeerrrraaaattttoooorrrr<<<<((((ccccoooonnnnsssstttt TTTT&&&&)))) or equivalent). bool ooooppppeeeerrrraaaattttoooorrrr========(const RWTValMultiSet<T,C>& s) const; bool ooooppppeeeerrrraaaattttoooorrrr========(const container_type& s) const; Returns ttttrrrruuuueeee if self compares equal to ssss, otherwise returns ffffaaaallllsssseeee. Two collections are equal if both have the same number of entries, and iterating through both collections produces, in turn, individual elements that compare equal to each other. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss void aaaappppppppllllyyyy(void (*fn)(const_reference,void*), void* d) const; Applies the user-defined function pointed to by ffffnnnn to every item in the collection. This function must have prototype: void yourfun(const_reference a, void* d); Client data may be passed through parameter dddd. iterator bbbbeeeeggggiiiinnnn(); const_iterator bbbbeeeeggggiiiinnnn() const; Returns an iterator positioned at the first element of self. void cccclllleeeeaaaarrrr(); PPPPaaaaggggeeee 3333 RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt((((3333CCCC++++++++)))) RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt((((3333CCCC++++++++)))) Clears the collection by removing all items from self. Each item will have its destructor called. bool ccccoooonnnnttttaaaaiiiinnnnssss(const_reference a) const; Returns ttttrrrruuuueeee if there exists an element tttt in self that compares equal to aaaa, otherwise returns ffffaaaallllsssseeee. bool ccccoooonnnnttttaaaaiiiinnnnssss(bool (*fn)(const_reference, void*), void* d) const; Returns ttttrrrruuuueeee if there exists an element tttt in self such that the expression ((((((((****ffffnnnn))))((((tttt,,,,dddd)))))))) is ttttrrrruuuueeee, otherwise returns ffffaaaallllsssseeee. ffffnnnn points to a user-defined tester function which must have prototype: bool yourTester(const_reference a, void* d); Client data may be passed through parameter dddd. void ddddiiiiffffffffeeeerrrreeeennnncccceeee(const RWTValMultiSet<T,C>& s); void ddddiiiiffffffffeeeerrrreeeennnncccceeee(const container_type& s); Sets self to the set-theoretic difference given by ((((sssseeeellllffff ---- ssss)))). iterator eeeennnndddd(); const_iterator eeeennnndddd() const; Returns an iterator positioned "just past" the last element in self. size_type eeeennnnttttrrrriiiieeeessss() const; Returns the number of items in self. bool ffffiiiinnnndddd(const_reference a, T& k) const; PPPPaaaaggggeeee 4444 RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt((((3333CCCC++++++++)))) RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt((((3333CCCC++++++++)))) If there exists an element tttt in self that compares equal to aaaa, assigns tttt to kkkk and returns ttttrrrruuuueeee. Otherwise, returns ffffaaaallllsssseeee and leaves the value of kkkk unchanged. bool ffffiiiinnnndddd(bool (*fn)(const_reference,void*), void* d, T& k) const; If there exists an element tttt in self such that the expression ((((((((****ffffnnnn))))((((tttt,,,,dddd)))))))) is ttttrrrruuuueeee, assigns tttt to kkkk and returns ttttrrrruuuueeee. Otherwise, returns ffffaaaallllsssseeee and leaves the value of kkkk unchanged. ffffnnnn points to a user- defined tester function which must have prototype: bool yourTester(const_reference a, void* d); Client data may be passed through parameter dddd. void iiiinnnntttteeeerrrrsssseeeeccccttttiiiioooonnnn(const RWTValMultiSet<T,C>& s); void iiiinnnntttteeeerrrrsssseeeeccccttttiiiioooonnnn(const container_type& s); Sets self to the intersection of self and ssss. bool iiiinnnnsssseeeerrrrtttt(const_reference a); Adds the item aaaa to the collection. Returns ttttrrrruuuueeee. bool iiiissssEEEEmmmmppppttttyyyy() const; Returns ttttrrrruuuueeee if there are no items in the collection, ffffaaaallllsssseeee otherwise. bool iiiissssEEEEqqqquuuuiiiivvvvaaaalllleeeennnntttt(const RWTValMultiSet<T,C>& s) const; Returns ttttrrrruuuueeee if there is set equivalence between self and ssss, and returns ffffaaaallllsssseeee otherwise. bool iiiissssPPPPrrrrooooppppeeeerrrrSSSSuuuubbbbsssseeeettttOOOOffff(const RWTValMultiSet<T,C>& s) const; PPPPaaaaggggeeee 5555 RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt((((3333CCCC++++++++)))) RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt((((3333CCCC++++++++)))) Returns ttttrrrruuuueeee if self is a proper subset of ssss, and returns ffffaaaallllsssseeee otherwise. bool iiiissssSSSSuuuubbbbsssseeeettttOOOOffff(const RWTValMultiSet<T,C>& s) const; Returns ttttrrrruuuueeee if self is a subset of ssss or if self is set equivalent to rrrrhhhhssss, ffffaaaallllsssseeee otherwise. size_type ooooccccccccuuuurrrrrrrreeeennnncccceeeessssOOOOffff(const_reference a) const; Returns the number of elements tttt in self that compare equal to aaaa. size_type ooooccccccccuuuurrrrrrrreeeennnncccceeeessssOOOOffff(bool (*fn)(const_reference,void*),void* d) const; Returns the number of elements tttt in self such that the expression((((((((****ffffnnnn))))((((tttt,,,,dddd)))))))) is ttttrrrruuuueeee. ffffnnnn points to a user-defined tester function which must have prototype: bool yourTester(const_reference a, void* d); Client data may be passed through parameter dddd. bool rrrreeeemmmmoooovvvveeee(const_reference a); Removes the first element tttt in self that compares equal to aaaa and returns ttttrrrruuuueeee. Returns ffffaaaallllsssseeee if there is no such element. bool rrrreeeemmmmoooovvvveeee(bool (*fn)(const_reference,void*), void* d); Removes the first element tttt in self such that the expression ((((((((****ffffnnnn))))((((tttt,,,,dddd)))))))) is ttttrrrruuuueeee and returns ttttrrrruuuueeee. Returns ffffaaaallllsssseeee if there is no such element. ffffnnnn points to a user-defined tester function which must have prototype: PPPPaaaaggggeeee 6666 RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt((((3333CCCC++++++++)))) RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt((((3333CCCC++++++++)))) bool yourTester(const_reference a, void* d); Client data may be passed through parameter dddd. size_type rrrreeeemmmmoooovvvveeeeAAAAllllllll(const_reference a); Removes all elements tttt in self that compare equal to aaaa. Returns the number of items removed. size_type rrrreeeemmmmoooovvvveeeeAAAAllllllll(bool (*fn)(const_reference,void*), void* d); Removes all elements tttt in self such that the expression ((((((((****ffffnnnn))))((((tttt,,,,dddd))))))))is ttttrrrruuuueeee. Returns the number of items removed. ffffnnnn points to a user-defined tester function which must have prototype: bool yourTester(const_reference a, void* d); Client data may be passed through parameter dddd. multiset<T,C,allocator>& ssssttttdddd(); const multiset<T,C,allocator>& ssssttttdddd() const; Returns a reference to the underlying C++-standard collection that serves as the implementation for self. This reference may be used freely, providing access to the C++-standard interface as well as interoperability with other software components that make use of the C++-standard collections. void ssssyyyymmmmmmmmeeeettttrrrriiiiccccDDDDiiiiffffffffeeeerrrreeeennnncccceeee(const RWTValMultiSet<T,C>& s); void ssssyyyymmmmmmmmeeeettttrrrriiiiccccDDDDiiiiffffffffeeeerrrreeeennnncccceeee(const container_type& s); Sets self to the symmetric difference of self and ssss. void UUUUnnnniiiioooonnnn(const RWTValMultiSet<T,C>& s); void PPPPaaaaggggeeee 7777 RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt((((3333CCCC++++++++)))) RRRRWWWWTTTTVVVVaaaallllMMMMuuuullllttttiiiiSSSSeeeetttt((((3333CCCC++++++++)))) UUUUnnnniiiioooonnnn(const container_type& s); Sets self to the union of self and ssss. Note the use of the uppercase "U"in UUUUnnnniiiioooonnnn to avoid conflict with the C++ reserved word. RRRReeeellllaaaatttteeeedddd GGGGlllloooobbbbaaaallll OOOOppppeeeerrrraaaattttoooorrrrssss RWvostream& ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(RWvostream& strm, const RWTValMultiSet<T,C>& coll); RWFile& ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(RWFile& strm, const RWTValMultiSet<T,C>& coll); Saves the collection ccccoooollllllll onto the output stream ssssttttrrrrmmmm, or a reference to it if it has already been saved. RWvistream& ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(RWvistream& strm, RWTValMultiSet<T,C>& coll); RWFile& ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(RWFile& strm, RWTValMultiSet<T,C>& coll); Restores the contents of the collection ccccoooollllllll from the input stream ssssttttrrrrmmmm. RWvistream& ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(RWvistream& strm, RWTValMultiSet<T,C>*& p); RWFile& ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(RWFile& strm, RWTValMultiSet<T,C>*& p); Looks at the next object on the input stream ssssttttrrrrmmmm and either creates a new collection off the heap and sets pppp to point to it, or sets pppp to point to a previously read instance. If a collection is created off the heap, then you are responsible for deleting it. PPPPaaaaggggeeee 8888